#include "datafilereader.h"

#include "../projector/projector.h"
#include "../projector/projectordata.h"

#include <QTCore/QIODevice>
#include <QTCore/QFile>
#include <QTCore/QStringList>

#ifdef DEBUG
#include <QTCore/QDebug>
#endif

namespace FileManagement
{

    
    DataFileReader::DataFileReader()
    {


    }

    DataFileReader::~DataFileReader()
    {

    }

    // reads the datafile and creates a QList of projector objects
    static void Read(const QString *filename)
    {
        QFile dataFile( *filename );

        if(!dataFile.exists() )
        {
#ifdef DEBUG
            qDebug() << "The file does not exists";
#endif
        }

        if( !dataFile.open( QIODevice::ReadOnly ))
        {
#ifdef DEBUG
            qDebug() << "The file could not be opened";
#endif
        }

#ifdef DEBUG
        qDebug() << "It worked.";
#endif

        // go over each line and take the attributes
        while( !dataFile.atEnd() )
        {
            // split the tab delimited file up
            QString line = dataFile.readLine();
            QStringList tokens = line.split('\t');

            // TODO: find out the what type of projector and create the projector based on that type

            

        }
        dataFile.close();


    }

}
